package bTree.LeetCode;

public class 完全二叉树的节点个数 {
    int num=0;
    public int countNodes(TreeNode root) {
        if(root==null){
            return 0;
        }
        dfs(root);
        return num;
    }

    private void dfs(TreeNode root) {
        if(root==null){
            return;
        }
        num++;
        dfs(root.left);
        dfs(root.right);
    }
}